Skip to content

Comments

handling unsupported lang switch gracefully#224

Merged
rootflo-hardik merged 2 commits intodevelopfrom
feat_handle_invalid_language_voice_agent
Feb 23, 2026
Merged

handling unsupported lang switch gracefully#224
rootflo-hardik merged 2 commits intodevelopfrom
feat_handle_invalid_language_voice_agent

Conversation

@rootflo-hardik
Copy link
Contributor

@rootflo-hardik rootflo-hardik commented Feb 20, 2026

Summary by CodeRabbit

  • New Features

    • Strengthened multi-language mode with language-switching rules that persist across switches
    • Improved detection for language-switch intent with clearer guidance to avoid false triggers
    • Added Kannada as a supported, human-readable language option
  • Bug Fixes

    • More user-friendly error responses when attempting unsupported language switches
    • Tightened validation to prevent switching to unsupported languages

@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

Refines unsupported-language error handling and updates language-switching behavior: language_detection now returns a user-facing error and logs a warning when a requested language is unsupported; pipecat_service appends explicit language-switching rules to the system prompt in multi-language mode; Kannada added to human-readable language map.

Changes

Cohort / File(s) Summary
Language Detection Error Handling
wavefront/server/apps/call_processing/call_processing/services/language_detection_tool.py
When target_language is unsupported, the service now logs a warning and returns an inlined, user-facing error payload via the callback; previous error-string construction/logging removed. Control flow unchanged: failed validation → callback with error → no switch.
Language Switching Rules / System Prompt
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py
Adds explicit "LANGUAGE SWITCHING RULES" text to the base system prompt when multi-language mode is active, persists rules across switches by storing them with the original prompt, and tightens language-switch detection guidance (explicit intent, restrict to supported languages, examples and "do not trigger" cases).
Language Mapping
wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py
Adds 'kn': 'Kannada' to the LANGUAGE_NAMES mapping for human-readable language names; no other logic changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through prompts and tiny rules,

added Kannada to my language tools,
warned when switches went astray,
and gently nudged the bot to stay —
a tidy change to light the way.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'handling unsupported lang switch gracefully' directly relates to the main objective of the pull request, which is to improve error handling when users attempt to switch to unsupported languages.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat_handle_invalid_language_voice_agent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)

313-325: System prompt ordering differs between initial setup and post-switch.

On initial setup (Line 321), the prompt is assembled as:
base → language_instruction → language_switching_rules

After a language switch in language_detection_tool.py (Line 153 of that file), it becomes:
base + language_switching_rules → language_instruction

The section order flips. This is unlikely to cause functional problems since LLMs are order-insensitive for disjoint system prompt sections, but if you want consistency, you could reorder Line 321 to match the post-switch layout:

Optional: align initial ordering with post-switch ordering
-            system_content = f'{base_system_prompt}\n\n{initial_language_instruction}{language_switching_rules}'
+            system_content = f'{base_system_prompt}{language_switching_rules}\n\n{initial_language_instruction}'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
around lines 313 - 325, The initial system prompt assembly order differs from
the post-switch assembly; update the construction in pipecat_service.py so
system_content and language_state['original_system_prompt'] use the same
ordering as the post-switch behavior: concatenate base_system_prompt +
language_switching_rules first, then append initial_language_instruction (i.e.,
make system_content = base_system_prompt + language_switching_rules + "\n\n" +
initial_language_instruction) and store language_state['original_system_prompt']
using the same base_system_prompt + language_switching_rules ordering so it
matches the language_detection_tool.py post-switch sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Around line 313-325: The initial system prompt assembly order differs from the
post-switch assembly; update the construction in pipecat_service.py so
system_content and language_state['original_system_prompt'] use the same
ordering as the post-switch behavior: concatenate base_system_prompt +
language_switching_rules first, then append initial_language_instruction (i.e.,
make system_content = base_system_prompt + language_switching_rules + "\n\n" +
initial_language_instruction) and store language_state['original_system_prompt']
using the same base_system_prompt + language_switching_rules ordering so it
matches the language_detection_tool.py post-switch sequence.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py (1)

152-190: 'kn' addition is correct; consider also adding other Nova-3 January 2026 languages.

Deepgram's January 21, 2026 Nova-3 release added Kannada (kn) alongside 11 other languages: Belarusian (be), Bengali (bn), Bosnian (bs), Croatian (hr), Macedonian (mk), Marathi (mr), Serbian (sr), Slovenian (sl), Tamil (ta), Tagalog (tl), and Telugu (te).

Of those, ta and te are already in DEEPGRAM_STT_LANGUAGES, but bn, bs, hr, mk, mr, sr, sl, be, and tl are currently absent. Some of these (bn, mr) are already in SARVAM_LANGUAGES and CARTESIA_LANGUAGES, and tl is in CARTESIA_LANGUAGES, so their omission from DEEPGRAM_STT_LANGUAGES could cause false validation failures if those language codes are ever used with Deepgram STT.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py`
around lines 152 - 190, DEEPGRAM_STT_LANGUAGES is missing several languages
added in Deepgram Nova-3 (Jan 21, 2026) which can cause false validation
failures; update the DEEPGRAM_STT_LANGUAGES set to include the missing language
codes: be, bn, bs, hr, mk, mr, sr, sl, tl (kn is already added and ta/te are
present), then run unit/validation tests that exercise language acceptance in
language_validation.py to ensure no regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py`:
- Around line 152-190: DEEPGRAM_STT_LANGUAGES is missing several languages added
in Deepgram Nova-3 (Jan 21, 2026) which can cause false validation failures;
update the DEEPGRAM_STT_LANGUAGES set to include the missing language codes: be,
bn, bs, hr, mk, mr, sr, sl, tl (kn is already added and ta/te are present), then
run unit/validation tests that exercise language acceptance in
language_validation.py to ensure no regressions.

@rootflo-hardik rootflo-hardik merged commit 6890d90 into develop Feb 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants